package com.enjoyor.soa.traffic.rest.efoms.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.api.dto.efoms.DeviceFaultCollectInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceUnnormalCollectInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.RepairsInfoDto;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.ISurveyDeviceCollectInfoConsumeService;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;

@Auth
@RestController
@RequestMapping({ "/faultCollect" })
@Api("设备故障数量统计")
@CrossOrigin

public class SurveyDeviceCollectInfoController {

	@Autowired
	private ISurveyDeviceCollectInfoConsumeService deviceUnnormalCollectInfoConsumeService;
	
	/**
     * 总体故障数量统计(监测首页，最上侧，下方异常数量统计)；
     * @return
     */
	@GetMapping(value = { "/selectDeviceFaultCollectInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceFaultCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("总体故障数量统计(监测首页，最上侧下方异常数量统计)")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo selectDeviceFaultCollectInfoList(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.selectDeviceFaultCollectInfoList(devTypeCode);
	}
	
	/**
     * 根据设备类型获取设备故障数量和故障总数（右侧中间饼形图）；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/selectDeviceFaultCollectByDevTypeCode" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceFaultCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("根据设备类型获取设备故障数量和故障总数（右侧中间饼形图）")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo selectDeviceFaultCollectByDevTypeCode(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.selectDeviceFaultCollectByDevTypeCode(devTypeCode);
	}
	
	/**设备故障；
     * 根据设备类型，按照部门分组统计故障数量统计（右侧中间条形图）；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/selectDevFaColGroupByDepId" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceFaultCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("设备故障（根据设备类型，按照部门分组统计故障数量统计（右侧中间条形图）；）")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo selectDevFaColGroupByDepId(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.selectDevFaColGroupByDepId(devTypeCode);
	}
	
	/**
     * 获取异常设备数量（监测首页，包含设备健康度统计部门）；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getDeviceUnnormalCollectInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("获取异常设备数量（监测首页，包含设备健康度统计部门）")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getDeviceUnnormalCollectInfoList(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getDeviceUnnormalCollectInfoList(devTypeCode);
	}
	
	/**设备异常
     * 左侧中间：总数、报修、故障、监测数量统计；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getFaultCollectReal" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("设备异常：（左侧中间：总数、报修、故障、监测数量统计）")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getFaultCollectReal(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getFaultCollectReal(devTypeCode);
	}
	
	/**设备异常
     * 异常趋势图；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getFaultCollectRealTrend" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("设备异常：异常趋势图")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "beginTime", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getFaultCollectRealTrend(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getFaultCollectRealTrend(devTypeCode,beginTime,endTime);
	}
	
	/**
     * 左侧中间：设备总览条形图统计（按部门分区）；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getDeviceUnNorForArea" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("左侧中间：设备总览条形图统计（按部门分区）")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getDeviceUnNorForArea(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getDeviceUnNorForArea(devTypeCode);
	}
	
	/**右侧下方：故障维修情况
     * （维修、立案、完成数量统计）；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getDeviceNowCollectSum" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("右侧下方：故障维修情况（维修、立案、完成数量统计）")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型", paramType = "query", dataType = "String")})
	public ResultPojo getDeviceNowCollectSum(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getDeviceNowSum(beginTime, endTime,devTypeCode);
	}
	
	/**运维团队巡检工作
     * （右侧下方当日巡检设备数量）
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getCheckCountForDeptIdAndSum" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("运维团队巡检工作（右侧下方当日巡检设备数量）")
	public ResultPojo getCheckCountForDeptIdAndSum(
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getCheckCountForDeptIdAndSum();
	}
	
	/**运维团队巡检工作
     * 右侧下方当日巡检报修数量；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getRepCountForDeptIdAndSum" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=DeviceUnnormalCollectInfoDto.class, code = 0, message = "")
    @ApiOperation("运维团队巡检工作（右侧下方当日巡检报修数量）")
	public ResultPojo getRepCountForDeptIdAndSum(
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getRepCountForDeptIdAndSum();
	}
	
	/**（左侧下方：报修工作；饼形图统计）
     * 根据报修来源编号获取数量分组；
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getRepSourceCount" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=RepairsInfoDto.class, code = 0, message = "")
    @ApiOperation("（左侧下方：报修工作；饼形图统计）根据报修来源编号获取数量分组")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getRepSourceCount(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getRepSourceCount(devTypeCode);
	}
	
	/**（左侧下方：报修工作；报修单位排名统计）
     * 分部门获取设备故障数量
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getRepSourceCountForDept" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=RepairsInfoDto.class, code = 0, message = "")
    @ApiOperation("（左侧下方：报修工作；报修单位排名统计）分部门获取设备故障数量")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getRepSourceCountForDept(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getRepSourceCountForDept(devTypeCode);
	}
	
	/**
     * 运维团队工作量统计
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/selectOppmWorkCollectInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=RepairsInfoDto.class, code = 0, message = "")
    @ApiOperation("运维团队工作量统计")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo selectOppmWorkCollectInfoList(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.selectOppmWorkCollectInfoList(devTypeCode);
	}
	
	/**
     * 统计今日报警数量
     * @param devTypeCode
     * @return
     */
	@GetMapping(value = { "/getWarningCountForToday" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("统计今日报警数量")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String")})
	public ResultPojo getWarningCountForToday(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return deviceUnnormalCollectInfoConsumeService.getWarningCountForToday(devTypeCode);
	}
}
